package net.dl.ss.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class BaseController {

	protected void modifyResponseHeader(HttpServletResponse response, String contentType) {
		response.setHeader("Cache-Control","no-store"); 
	    response.setHeader("Pragma","no-cache");
	    response.setContentType(contentType);
	}
	
	protected <T> T getParameter(HttpServletRequest request, String name, Class<? extends T> clazz) {
		String parameter = request.getParameter(name);
		if(parameter!=null && !"".equals(parameter)) {
			try {
				return clazz.getConstructor(String.class).newInstance(parameter);
			} catch(Exception e) {
				return null;
			}
		}
		return null;
	}
	
}
